package com.medaxis.hpams.sso.service.impl;

import com.medaxis.hpams.sso.domain.Menu;
import com.medaxis.hpams.sso.mapper.MenuMapper;
import com.medaxis.hpams.sso.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Service
public class MenuServiceImpl implements MenuService {
    @Autowired
    MenuMapper menuMapper;

    @Override
    public List<Menu> selectMenuList(Menu menu) {
      return menuMapper.selectMenuList(menu);
    }

    @Override
    public Collection<String> selectMenuPermsByUserId(Long userId) {
        ArrayList<String> list  = new ArrayList<>();
        List<Menu> menuList= menuMapper.selectMenuListByUserId(userId);
      menuList.forEach(menu -> {
          list.add(menu.getPerms());
      });
        return list;
    }
}
